srcdir       = @srcdir@
top_builddir = @top_builddir@
top_srcdir   = @top_srcdir@

include ../Makefile.ext

SCM_CATEGORY = dbm

LIBFILES = @DBM_ARCHFILES@
SCMFILES = @DBM_SCMFILES@
OBJECTS  = @DBM_OBJECTS@

GENERATED = Makefile dbmconf.h
XCLEANFILES = dbm--gdbm.c gdbm.sci \
              dbm--ndbm.c ndbm.sci \
              dbm--odbm.c odbm.sci \
              ndbm-makedb ndbm-suffixes.h

all : $(LIBFILES)

gdbm_OBJECTS   = dbm--gdbm.$(OBJEXT)

dbm--gdbm.$(SOEXT) : $(gdbm_OBJECTS)
	$(MODLINK) dbm--gdbm.$(SOEXT) $(gdbm_OBJECTS) $(EXT_LIBGAUCHE) @GDBMLIB@ $(LIBS)

gdbm.sci dbm--gdbm.c : gdbm.scm
	$(PRECOMP) -e -P -o dbm--gdbm $(srcdir)/gdbm.scm

ndbm_OBJECTS   = dbm--ndbm.$(OBJEXT)

dbm--ndbm.$(SOEXT) : $(ndbm_OBJECTS)
	$(MODLINK) dbm--ndbm.$(SOEXT) $(ndbm_OBJECTS) $(EXT_LIBGAUCHE) @NDBMLIB@ $(LIBS)

ndbm.sci dbm--ndbm.c : ndbm.scm
	$(PRECOMP) -e -P -o dbm--ndbm $(srcdir)/ndbm.scm

dbm--ndbm.$(OBJEXT): dbm--ndbm.c ndbm-suffixes.h

odbm_OBJECTS   = dbm--odbm.$(OBJEXT)

dbm--odbm.$(SOEXT) : $(odbm_OBJECTS)
	$(MODLINK) dbm--odbm.$(SOEXT) $(odbm_OBJECTS) $(EXT_LIBGAUCHE) @ODBMLIB@ $(LIBS)

odbm.sci dbm--odbm.c : odbm.scm
	$(PRECOMP) -e -P -o dbm--odbm $(srcdir)/odbm.scm


# auxiliary stuff to find out the extension of ndbm file(s).
ndbm-makedb : ndbm-makedb.c
	$(CC) $(DEFS) $(INCLUDES) $(CPPFLAGS) $(CFLAGS) -o ndbm-makedb \
	  $(srcdir)/ndbm-makedb.c $(LOCAL_LFLAGS) $(XLDFLAGS) @NDBMLIB@ $(LIBS)

ndbm-suffixes.h : ndbm-makedb ndbm-suffixes.scm
	$(GOSH) $(srcdir)/ndbm-suffixes.scm ndbm-suffixes.h

install : install-std

